<template name="home">
  <div class="home" >
    <el-container >
      <!-- 左侧菜单栏 -->
      <el-aside width="220px">
        <el-menu
        default-active="2"
        class="el-menu-vertical-demo"
        @open="handleOpen"
        @close="handleClose"
        background-color="#CDD7E5"
        :collapse="iscollapse"
        >
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>UserGroupManage</span>
            </template>
              <el-menu-item index="2" @click="ToUserGroup">
                <!-- <router-link to="./Usergroup.vue"> -->
                  <i class="el-icon-menu"></i>
                  <span slot="title">UserGroupList</span>
                <!-- </router-link> -->
              </el-menu-item>
          </el-submenu>
          <el-submenu index="3">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>UserManagement</span>
            </template>
            <el-menu-item index="3-1" @click="ToUsersList">
                <i class="el-icon-menu"></i>
                <span slot="title">UserList</span>
              </el-menu-item>
              <el-menu-item index="3-2" @click="ToUsersLog">
                <i class="el-icon-menu"></i>
                <span slot="title">UserLog</span>
              </el-menu-item>
          </el-submenu>

           <el-submenu index="4">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>RightManagement</span>
            </template>
            <el-menu-item index="4-1" @click="ToRightList">
                <i class="el-icon-menu"></i>
                <span slot="title">RightList</span>
              </el-menu-item>
             
          </el-submenu>

          <el-menu-item index="5" @click="ToSystemComfig">
            <i class="el-icon-setting"></i>
            <span slot="title">SystemConfiguration</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <!-- 右侧内容 -->
      <el-container>
        <el-header>
          <div class="title">
            <span class="system">User Management System</span>
            <div class="loginOut fr">
              <span class="welcome">Hello，{{username}}</span>
              <el-button type="warning" plain @click="logout">Sign out</el-button>
            </div>
          </div>
        </el-header>
        <el-main>
          <transition
            enter-active-class="animated fadeIn"
            leave-active-class="animated fadeOut"
            mode="out-in"
          >
            <!-- 用于子路由的组件 -->
            <router-view></router-view>
          </transition>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
  export default{
    data(){
      return{
        iscollapse:false,     //默认展开
        username:""
      }
    },
    created () {
      this.username=localStorage.getItem("username")
      // console.log(this.username)
    },
    methods: {
      handleOpen(key, keyPath) {
        // console.log(key, keyPath);
      },
      handleClose(key, keyPath) {
        // console.log(key, keyPath);
      },
      // 路由跳转
      // 跳转到用户组列表页
      ToUserGroup(){
        this.$router.push({
          name:'usergroup'
        })
      },
      // 跳转到用户列表页
      ToUsersList(){
        this.$router.push({
          name:'userslist'
        })
      },
      // 跳转到用户日志页
      ToUsersLog(){
        this.$router.push({
          // name:'userslog'
          path: '/userslog',
        })
      },
      // 跳转到系统配置页面
      ToSystemComfig(){
        this.$router.push({
          name:'systemconfig'
        })
      },
      // 退出登录
      logout () {
        // 清空本地存储
        localStorage.clear();
        // 跳转到登录页
        this.$router.push({ name: 'login' })
    },
    // 跳转到权限列表
    ToRightList(){
      this.$router.push({
        name:'rightlist'
      })
    }
    }
  }
</script>
<style lang="scss" scoped>
// 高度待整改
.el-container{
  height: 650px;
}
  .el-header {
    background-color: #E9E9E9;
    color: #000;
    text-align: center;
    line-height: 60px;
  }
  
  .el-aside {
    background-color: #fff;
    color: #000;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    line-height: 200px;
    .el-menu-item, .el-submenu__title{
    height: 40px;
    line-height: 40px;
  }
  }
  .el-aside .el-submenu__title * ,.el-menu-item * {
      color: #000;
      font-family:  "SF Pro Text","Myriad Set Pro","SF Pro Icons","Apple Legacy Chevron","Helvetica Neue","Helvetica","Arial",sans-serif;
    }
  .el-aside .el-menu{
      border-right: none;
    }

  .el-main {
    background-color: #F6F6F6;
    color: #333;
    text-align: center;
    line-height: 160px;
  }
  
  .toggle-btn {
    padding: 0 15px;
    margin-left: -20px;
    font-size: 36px;
    color: white;
    cursor: pointer;
    line-height: 60px;
  }
  
.title .system{
      font-size:24px;
      color:#000;
    }

.title .welcome{
      color: #000;
      margin-right: 20px;
    }
.title .userInfo{
      background-color: red;
    }

</style>

